package cz.muni.fi.pa165.ddtroops.daoclasses;

import cz.muni.fi.pa165.ddtroops.daointerfaces.HeroDAO;
import cz.muni.fi.pa165.ddtroops.entities.Hero;
import org.springframework.stereotype.Repository;

/**
 * Class HeroDAO serves as a Data Access Object class for entity Hero.
 * HeroDAO class extends generic abstract class BaseDAOImpl, see HeroDAO for
 * set of supported methods.
 * 
 * @author Erik Vaněk
 */
@Repository(value = "heroDAO")
public class HeroDAOImpl extends BaseDAOImpl<Hero> implements HeroDAO
{
    @Override
    protected boolean isValid(Hero hero) {
        return ((hero.getXp() != null) && 
             hero.getName() != null && !hero.getName().isEmpty() &&
             hero.getGender() != null && 
             hero.getBelief() != null && !hero.getBelief().isEmpty() &&
             hero.getProfession() != null && !hero.getProfession().isEmpty() &&
             hero.getSkills() != null &&
             hero.getRace() != null &&
             hero.getStrength() != null && 
             hero.getDexterity() != null &&
             hero.getConstitution() != null && 
             hero.getIntelligence() != null &&
             hero.getWisdom() != null &&
             hero.getCharisma()  != null);
    }

    @Override
    protected boolean isIn(Hero object) 
    {
        return getById(object.getId()) != null;
    }
}
